<template>
  <el-dialog
      title="学校公告修改"
      :visible.sync="visible"
      :close-on-click-modal="false"
      width="40%">
       <el-input
        type="textarea"
        :autosize="{ minRows: 8, maxRows: 4}"
        placeholder="请输入公告"
        v-model="notice" />
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">取 消</el-button>
        <el-button type="primary" @click="auditComfig">确 定</el-button>
      </span>
    </el-dialog>
</template>

<script>
import {
  Vue,
  ref,
  toRefs,
  shallowRef,
  reactive,
  watch,
  watchEffect,
  getCurrentInstance,
  computed,
  defineComponent,
  nextTick,
  inject,
  onMounted,
  onUnmounted
} from 'vue'
import { Message,MessageBox } from 'element-ui'
import {setSchoolNoticeEdit} from '@/api/school/school_api.js'
export default {
  name: 'notice',
  setup(props, { emit }) {
   // const emits = defineEmits(['onOk'])
    const Interface = reactive({
      formClick(row){
        query.id = row.id
        query.notice = row.notice
        query.visible = true
      },
      async auditComfig(){
        if(!query.notice){
          return Message.error('公告不能为空！')
        }
        let params = {}
        params.id = query.id
        params.notice = query.notice
       const {code} = await setSchoolNoticeEdit(params)
        if(code === 0){
          Message.success('操作成功')
          query.visible = false
          emit('onOk')
        }
      }
    })
    const query = reactive({
      visible:false,
      notice:'',
      id:''
    })
    return {
      ...toRefs(query),
      ...toRefs(Interface)
    }
  }
}
</script>
